package cn.sciento.farm.devicemanager.service.impl;

import cn.sciento.farm.devicemanager.dao.entity.DevCollectionType;
import cn.sciento.farm.devicemanager.dao.mapper.CollectionTypeMapper;
import cn.sciento.farm.devicemanager.service.CollectionTypeService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CollectionTypeServiceImpl implements CollectionTypeService {

    @Autowired
    private CollectionTypeMapper collectionTypeMapper;

    @Override
    public DevCollectionType getById(String circuit) {
        return collectionTypeMapper.selectById(circuit);
    }

    @Override
    public List<DevCollectionType> list() {
        return collectionTypeMapper.selectList(null);
    }

    @Override
    public int add(DevCollectionType collectionType) {
        return collectionTypeMapper.insert(collectionType);
    }

    // todo 这个没有测试
    @Override
    public int updateById(DevCollectionType collectionType) {
        return collectionTypeMapper.updateById(collectionType);
    }

    @Override
    public DevCollectionType getBySerial(Integer serial) {
        QueryWrapper queryWrapper = new QueryWrapper<DevCollectionType>();
        queryWrapper.eq("serial",serial);
        DevCollectionType collectionType = collectionTypeMapper.selectOne(queryWrapper);
        return collectionType;
    }
}
